package com.damai.mvc.view.imple;

import java.lang.reflect.Method;

import com.damai.action.IRender;
import com.damai.action.IRenderFactory;
import com.damai.annotation.Crypt;

public class JsonRenderFactory implements IRenderFactory {

	public static final IRenderFactory DEFAULT = new JsonRenderFactory();
	
	private JsonRenderFactory(){
		
	}
	
	private boolean needsEncrypt(Method method){
		Crypt crypt = method.getAnnotation(Crypt.class);
		if(crypt==null)return false;
		if(  (crypt.value() & Crypt.DOWNLOAD) >0 ){
			return true;
		}
		return false;
	}
	@SuppressWarnings("rawtypes")
	@Override
	public IRender createRender(Object controller, Method method) {
		if(needsEncrypt(method)){
			return EncRender.DEFAULT;
		}
		return DefRender.DEFAULT;
	}

}
